package com.bjesc_b2c.app.appraiset.mvp.model.impl;

import android.content.Context;

import com.bjesc_b2c.app.appraiset.http.IApiActivityRequest;
import com.bjesc_b2c.app.appraiset.mvp.model.CarOffShelfModel;
import com.rxretrofit_build.util.MapUtil;

import java.util.HashMap;

import master_bean.CarOffShelfBean;
import master_bean.CarSeriesModelBean;
import rxretrofit_base.model.ShowType;
import rxretrofit_base.model.TokenBean;
import rxretrofit_base.net.BaseSubscriber;
import rxretrofit_base.net.RxRequest;

/**
 * Created by yidong on 2017/5/9.
 */

public class CarOffShelfModelImpl implements CarOffShelfModel {

    private CallBack callBack;

    public CarOffShelfModelImpl(CallBack callBack) {
        this.callBack = callBack;
    }

    @Override
    public void pustCarOff(Context context, CarOffShelfBean bean) {

        HashMap<String, Object> build = new MapUtil()
                .put("type", bean.getType())
                .put("car_id", bean.getCar_id())
                .put("termination_car_type", bean.getTermination_car_type())
                .put("strike_price", bean.getStrike_price())
                .put("server_price", bean.getServer_price())
                .put("termination_car_text", bean.getTermination_car_text())
                .build();
        RxRequest.request(ShowType.SHOW, RxRequest.getClient(context, build).create(IApiActivityRequest.class).offCar(),
                new BaseSubscriber<TokenBean<CarSeriesModelBean>>(context) {
                    @Override
                    public void onSuccess(TokenBean<CarSeriesModelBean> o) {
                        if(callBack!=null){
                            callBack.callback(o.getData());
                        }
                    }

                    @Override
                    public void onFailure(Throwable e) {

                    }
                });
    }
    public interface CallBack{
        void callback(CarSeriesModelBean bean);
    }
}
